package library;

import java.sql.SQLException;

public class LibrarianController extends UserManager{
	
	public LibrarianController() throws SQLException{
		super(Librarian.class);
	}
	
	public Librarian check(String name, String password) throws Exception{
		Librarian librarian = this.getLibrarian(name);
		if(librarian.checkPassword(password))
			return librarian;
		else
			throw new Exception("Can not login Librarian, invalid password");
	}
	
	public Librarian getLibrarian(String userName) throws Exception{
		Librarian librarian;
		try{
			librarian = (Librarian)this.search(userName);
		} catch (Exception ex){
			throw new Exception("Librarian: " + userName + " not found");
		}
		return librarian;
	}

    public boolean create(Librarian newLibrarian) throws SQLException {
        return super.create(newLibrarian);
    }
}
